<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="wetechfn" uri="http://wetech.tech/admin/tags/wetech-functions" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<style>
    ul.ztree {
        border: 1px solid #ccc;
        background-color: #fff;
        height: 200px;
        overflow-y: scroll;
        overflow-x: auto;
    }
</style>
<!-- bootstrap datepicker -->


<!-- Content Header (Page header) -->
<section class="content-header" style="">
    <h1>
        企业信息录入
        <small></small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
        <li><a href="#">业务办理</a></li>
        <li class="active">企业信息录入</li>
    </ol>
</section>


<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-body">
                    <form class="form-horizontal" action="#" id="addCompanyInfo">

                        <div class="form-group ">
                            <label for="comName" class="col-sm-2 control-label"><span
                                    class="asterisk">*</span>名称</label>

                            <div class="col-sm-4 required">
                                <input type="text" class="form-control" id="comName" name="comName">
                            </div>

                            <label for="businessCode" class="col-sm-2 control-label" id="businessCodePLabel"
                                   style="display:none;"><span class="asterisk">*</span>身份证号</label>
                            <label for="businessCode" class="col-sm-2 control-label" id="businessCodeCLabel"><span
                                    class="asterisk">*</span>营业执照编号</label>

                            <div class="col-sm-4">
                                <input type="text" class="form-control" id="businessCode" name="businessCode">
                            </div>
                        </div>


                        <div class="form-group ">

                            <label for="businessType" class="col-sm-2 control-label"><span
                                    class="asterisk">*</span>业务类型</label>

                            <div class="col-sm-4">
                                <select class="form-control" id="businessType" name="businessType">
                                    <option value="1" selected="selected">供应链融资</option>
                                    <option value="2">企业经营贷</option>
                                    <option value="3">个人借款</option>
                                </select>
                            </div>

                            <label for="comType" class="col-sm-2 control-label"><span
                                    class="asterisk">*</span>企业类别</label>

                            <div class="col-sm-4">
                                <select class="form-control" id="comType" name="comType"
                                        onchange="comTypeChange()">
                                    <option value="1" selected="selected">核心企业</option>
                                    <option value="2">一般企业</option>
                                    <option value="3">个人</option>
                                    <option value="0">其他</option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group">

                            <label for="creditLine" id="creditLineLabel" class="col-sm-2 control-label "><span
                                    class="asterisk">*</span>授信额度(元)</label>

                            <div class="col-sm-4 required">
                                <input type="number" class="form-control" id="creditLine" name="creditLine">
                            </div>


                            <label for="creditLimit" id="creditLimitLabel" class="col-sm-2 control-label "><span
                                    class="asterisk">*</span>授信期限(年)</label>

                            <div class="col-sm-4 required ">
                                <select class="form-control" id="creditLimit" name="creditLimit">
                                    <option>1</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group">
                            <label for="inputTime" class="col-sm-2 control-label"><span
                                    class="asterisk">*</span>录入时间</label>

                            <div class="col-sm-4">
                                <input type="text" class="form-control  date form_datetime" id="inputTime"
                                       name="inputTime">
                            </div>

                            <label for="comId" class="col-sm-2 control-label">企业id</label>

                            <div class="col-sm-4 required">
                                <input type="text" class="form-control" id="comId" name="comId" value="0" readonly>
                            </div>


                        </div>

                        <div class="box-footer">
                            <button type="button" class="btn btn-info pull-right" id="submitAdd">保存</button>
                        </div>

                    </form>

                    <input id="id" type="hidden" name="id">

                    <form class="form-horizontal" action="#" id="imgCoreCompanyForm" name="imgCoreCompanyForm"
                          enctype="multipart/form-data"
                          style="display:none;">
                        <div class="panel">

                            <div class="form-group">
                                <label for="input-id1" class="col-sm-6 control-label" id="input-id1Label"><span
                                        class="asterisk">*</span>企业营业执照（副本）:</label>
                                <input id="input-id1" name="input-id1" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id2" class="col-sm-6 control-label" id="input-id2Label"><span
                                        class="asterisk">*</span>开户许可证:</label>
                                <input id="input-id2" name="input-id2" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id3" class="col-sm-6 control-label" id="input-id3Label"><span
                                        class="asterisk">*</span>机构信用代码证:</label>
                                <input id="input-id3" name="input-id3" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id4" class="col-sm-6 control-label" id="input-id4Label"><span
                                        class="asterisk">*</span>法人身份证:</label>
                                <input id="input-id4" name="input-id4" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id5" class="col-sm-6 control-label" id="input-id5Label">法人征信:</label>
                                <input id="input-id5" name="input-id5" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id6" class="col-sm-6 control-label" id="input-id6Label"><span
                                        class="asterisk">*</span>企业征信:</label>
                                <input id="input-id6" name="input-id6" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id7" class="col-sm-6 control-label" id="input-id7Label">验资报告:</label>
                                <input id="input-id7" name="input-id7" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id8" class="col-sm-6 control-label" id="input-id8Label"><span
                                        class="asterisk">*</span>公司章程:</label>
                                <input id="input-id8" name="input-id8" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id9" class="col-sm-6 control-label" id="input-id9Label"><span
                                        class="asterisk">*</span>年度报表:</label>
                                <input id="input-id9" name="input-id9" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id10" class="col-sm-6 control-label" id="input-id10Label"><span
                                        class="asterisk">*</span>月度报表:</label>
                                <input id="input-id10" name="input-id10" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id11" class="col-sm-6 control-label" id="input-id11Label">增值税纳税申报表:</label>
                                <input id="input-id11" name="input-id11" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id12" class="col-sm-6 control-label" id="input-id12Label"><span
                                        class="asterisk">*</span>销售合同:</label>
                                <input id="input-id12" name="input-id12" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id14" class="col-sm-6 control-label" id="input-id14Label"><span
                                        class="asterisk">*</span>采购合同:</label>
                                <input id="input-id14" name="input-id14" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id13" class="col-sm-6 control-label" id="input-id13Label"><span
                                        class="asterisk">*</span>法人夫妻双方的结婚证或户口本:</label>
                                <input id="input-id13" name="input-id13" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id15" class="col-sm-6 control-label" id="input-id15Label">电费发票:</label>
                                <input id="input-id15" name="input-id15" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id16" class="col-sm-6 control-label"
                                       id="input-id16Label">环评报告:</label>
                                <input id="input-id16" name="input-id16" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id17" class="col-sm-6 control-label" id="input-id17Label">银行流水:</label>
                                <input id="input-id17" name="input-id17" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>


                            <div class="form-group">
                                <label for="input-id18" class="col-sm-6 control-label" id="input-id18Label">从事特种行业的相关资质材料:</label>
                                <input id="input-id18" name="input-id18" type="file" data-show-caption="true"
                                       class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-id19" class="col-sm-6 control-label"
                                       id="input-id19Label">企业不动产证:</label>
                                <input id="input-id19" name="input-id19" type="file" data-show-caption="true"
                                       class="imagelimit">
                            </div>


                            <div class="form-group">
                                <label for="input-id20" class="col-sm-6 control-label" id="input-id20Label">担保措施为抵质押物的需提供抵质押物明细及相关材料:</label>
                                <input id="input-id20" name="input-id20" type="file" data-show-caption="true"
                                       class="imagelimit">

                            </div>
                            <div class="addcailiao">
                                <button type="button" class="ht_in_jia btn  pull-right">+ 新增材料</button>
                            </div>
                        </div>
                        <div class="box-footer">
                            <button type="button" class="btn btn-info pull-right tubtn">图片上传</button>
                        </div>
                    </form>


                    <form class="form-horizontal" action="#" id="imgCompanyForm" name="imgCompanyForm"
                          enctype="multipart/form-data"
                          style="display:none;">
                        <div class="panel">

                            <div class="form-group">
                                <label for="input-idC1" class="col-sm-6 control-label" id="input-idC1Label"><span
                                        class="asterisk">*</span>企业营业执照（副本）:</label>
                                <input id="input-idC1" name="input-idC1" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC2" class="col-sm-6 control-label" id="input-idC2Label"><span
                                        class="asterisk">*</span>开户许可证:</label>
                                <input id="input-idC2" name="input-idC2" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC3" class="col-sm-6 control-label" id="input-idC3Label"><span
                                        class="asterisk">*</span>机构信用代码证:</label>
                                <input id="input-idC3" name="input-idC3" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC4" class="col-sm-6 control-label" id="input-idC4Label"><span
                                        class="asterisk">*</span>法人身份证:</label>
                                <input id="input-idC4" name="input-idC4" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC5" class="col-sm-6 control-label" id="input-idC5Label">法人征信:</label>
                                <input id="input-idC5" name="input-idC5" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC6" class="col-sm-6 control-label" id="input-idC6Label"><span
                                        class="asterisk">*</span>企业征信:</label>
                                <input id="input-idC6" name="input-idC6" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC7" class="col-sm-6 control-label" id="input-idC7Label">验资报告:</label>
                                <input id="input-idC7" name="input-idC7" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC8" class="col-sm-6 control-label" id="input-idC8Label"><span
                                        class="asterisk">*</span>公司章程:</label>
                                <input id="input-idC8" name="input-idC8" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC9" class="col-sm-6 control-label" id="input-idC9Label"><span
                                        class="asterisk">*</span>年度报表:</label>
                                <input id="input-idC9" name="input-idC9" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC10" class="col-sm-6 control-label" id="input-idC10Label"><span
                                        class="asterisk">*</span>月度报表:</label>
                                <input id="input-idC10" name="input-idC10" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC11" class="col-sm-6 control-label" id="input-idC11Label">增值税纳税申报表:</label>
                                <input id="input-idC11" name="input-idC11" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC12" class="col-sm-6 control-label" id="input-idC12Label"><span
                                        class="asterisk">*</span>销售合同:</label>
                                <input id="input-idC12" name="input-idC12" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>


                            <div class="form-group">
                                <label for="input-idC13" class="col-sm-6 control-label" id="input-idC13Label"><span
                                        class="asterisk">*</span>法人夫妻双方的结婚证或户口本:</label>
                                <input id="input-idC13" name="input-idC13" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC15" class="col-sm-6 control-label" id="input-idC15Label">电费发票:</label>
                                <input id="input-idC15" name="input-idC15" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC16" class="col-sm-6 control-label"
                                       id="input-idC16Label">环评报告:</label>
                                <input id="input-idC16" name="input-idC16" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC17" class="col-sm-6 control-label" id="input-idC17Label">银行流水:</label>
                                <input id="input-idC17" name="input-idC17" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>


                            <div class="form-group">

                                <label for="input-idC18" class="col-sm-6 control-label" id="input-idC18Label">从事特种行业的相关资质材料:</label>
                                <input id="input-idC18" name="input-idC18" type="file" data-show-caption="true"
                                       class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idC19" class="col-sm-6 control-label"
                                       id="input-idC19Label">企业不动产证:</label>
                                <input id="input-idC19" name="input-idC19" type="file" data-show-caption="true"
                                       class="imagelimit">
                            </div>

                            <div class="addcailiao">
                                <button type="button" class="ht_in_jia btn  pull-right">+ 新增材料</button>
                            </div>
                        </div>
                        <div class="box-footer">
                            <button type="button" class="btn btn-info pull-right tubtn">图片上传</button>
                        </div>
                    </form>

                    <form class="form-horizontal" action="#" id="imgPersonForm" name="imgPersonForm"
                          enctype="multipart/form-data"
                          style="display:none;">
                        <div class="panel">

                            <div class="form-group">
                                <label for="input-idP1" class="col-sm-6 control-label" id="input-idP1Label"><span
                                        class="asterisk">*</span>借款人身份证:</label>
                                <input id="input-idP1" name="input-idP1" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idP2" class="col-sm-6 control-label" id="input-idP2Label"><span
                                        class="asterisk">*</span>户口本:</label>
                                <input id="input-idP2" name="input-idP2" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idP3" class="col-sm-6 control-label" id="input-idP3Label">结婚证:</label>
                                <input id="input-idP3" name="input-idP3" type="file"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idP4" class="col-sm-6 control-label" id="input-idP4Label"><span
                                        class="asterisk">*</span>个人最新人行征信:</label>
                                <input id="input-idP4" name="input-idP4" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idP5" class="col-sm-6 control-label" id="input-idP5Label"><span
                                        class="asterisk">*</span>有效的收入证明:</label>
                                <input id="input-idP5" name="input-idP5" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idP6" class="col-sm-6 control-label" id="input-idP6Label"><span
                                        class="asterisk">*</span>个人消费有关证明材料:</label>
                                <input id="input-idP6" name="input-idP6" type="file" required="required"
                                       data-show-caption="true" class="imagelimit">
                            </div>
                            <div class="form-group">
                                <label for="input-idP18" class="col-sm-6 control-label"
                                       id="input-idP18Label">个人资产证明:</label>
                                <input id="input-idP18" name="input-idP18" type="file" data-show-caption="true"
                                       class="imagelimit">
                            </div>
                            <div class="form-group">
                                <label for="input-idP19" class="col-sm-6 control-label"
                                       id="input-idP19Label">个人银行卡流水:</label>
                                <input id="input-idP19" name="input-idP19" type="file" data-show-caption="true"
                                       class="imagelimit">
                            </div>

                            <div class="form-group">
                                <label for="input-idP20" class="col-sm-6 control-label"
                                       id="input-idP20Label">借款后资金用途证明:</label>
                                <input id="input-idP20" name="input-idP20" type="file" data-show-caption="true"
                                       class="imagelimit">

                            </div>
                            <div class="addcailiao">
                                <button type="button" class="ht_in_jia btn  pull-right">+ 新增材料</button>
                            </div>
                        </div>
                        <div class="box-footer">
                            <button type="button" class="btn btn-info pull-right tubtn">图片上传</button>
                        </div>
                    </form>

                    <form class="form-horizontal" action="#" id="imgOthersForm" name="imgOthersForm"
                          enctype="multipart/form-data"
                          style="display:none;">
                        <div class="panel">
                            <div class="addcailiao">
                                <button type="button" class="ht_in_jia btn  pull-right">+ 新增材料</button>
                            </div>
                        </div>
                        <div class="box-footer">
                            <button type="button" class="btn btn-info pull-right tubtn">图片上传</button>
                        </div>
                    </form>

                    <div id="J_progress_label"
                         style="display: none;position: absolute;width: 200px;height: 60px;text-align: center;line-height: 60px;top: 0;left: 0;right: 0;bottom: 0;border-radius:15px;margin: auto;box-shadow:0px 0px 5px #e5f9f2;background:#f63;z-index:999;color:white;">

                    </div>


                </div>
            </div>
        </div>
    </div>
    <style>
        .panel {
            position: relative;
            overflow: hidden;
            min-height: 40px;
        }

        .addcailiao button:hover {
            color: white !important;
        }

        .panel .form-group {
            width: 50%;
            float: left;
            height: 40px;
            position: relative;
        }

        .clear:after {
            content: '';
            display: block;
            clear: both;
        }

        .clear {
            zoom: 1;
        }

        .addcailiao {
            position: absolute;
            right: 10px;
            bottom: 0px;
            z-index: 999;
        }

        .ht_in_jia {
            background: #f63;
            color: white;
        }

        .formspan {
            text-align: right;
        }

        .ht_in_jian {
            border: none;
            padding: 0px 10px;
            fot-size: 18px;
            color: white;
            background: #f63;
            position: absolute;
            right: 60px;
            top: 2px;
        }
    </style>
</section>


<script>

    // 业务类型切换
    function comTypeChange() {
        var objS = document.getElementById("comType");
        var selectI = objS.options[objS.selectedIndex].value;

        if (selectI == "3") {
            $("#businessCodeCLabel").attr("style", "display:none");
            $("#businessCodePLabel").attr("style", "display:block");
        } else {
            $("#businessCodePLabel").attr("style", "display:none");
            $("#businessCodeCLabel").attr("style", "display:block");
        }
    }

    //非空校验
    function checkInput(selectI) {

        var checkFlag = true;
        $("#addCompanyInfo :input").each(function () {
            var name = $(this).attr("id");
            if (name == "submitAdd" || name == "comId") {

            } else {
                if ($(this).val() == "") {
                    alert($('label[for="' + name + '"]').text() + "不能为空");
                    checkFlag = false;
                    return checkFlag;
                }
            }
        });
        return checkFlag;
    }
    //企业信息保存
    $("#submitAdd").click(function () {
        var data = $("#addCompanyInfo").serialize();
        var objS = document.getElementById("comType");
        var selectI = objS.options[objS.selectedIndex].value;
        if (checkInput(selectI)) {
            $("#submitAdd").attr("disabled", "disabled");
            $.ajax({
                type: 'post',
                url: '/company/saveCompanyInfo',
                cache: false,
                data: data,
                dataType: 'json',
                success: function (data) {
                    if (data.status == "0") {
                        $("#id").attr("value", data.id);
                        if (selectI == "1") {
                            $("#imgCoreCompanyForm").attr("style", "display:block");
                        }
                        if (selectI == "2") {
                            $("#imgCompanyForm").attr("style", "display:block");
                        }
                        if (selectI == "3") {
                            $("#imgPersonForm").attr("style", "display:block");
                        }
                        if (selectI == "0") {
                            $("#imgOthersForm").attr("style", "display:block");
                        }
                        //企业信息置为只读
                        $("#addCompanyInfo :input").each(function () {
                            $(this).attr("readonly", "readonly");
                        });
                    } else {
                        $("#submitAdd").removeAttr("disabled");
                    }
                    alert(data.message);
                },
                error: function () {
                    $("#submitAdd").removeAttr("disabled");
                    alert("修改企业信息失败");
                }
            })
        }
    })


    //图片非空校验
    function checkImageInput(that) {

        var checkFlag = true;
        $(that).parent().prev().find("input").each(function () {
            var type = $(this).attr("type");
            if (type == "file" && $(this).attr("style") != "display:none" && $(this).attr("required") == "required") {
                var name = $(this).attr("id");
                if ($(this).val() == "") {
                    $('label[for="' + name + '"]').each(function () {
                        if ($(this).attr("style") != "display:none") {
                            alert($(this).text() + "不能为空");
                            checkFlag = false;
                        }
                    });
                }
                return checkFlag;
            }
        });
        return checkFlag;
    }


    $(function () {
        var inputidnum = 31;
        $('.panel').on('click', '.ht_in_jia', function () {
            inputidnum++;
            var thisid = "input-id" + inputidnum;
            var thisidLabel = "input-id" + inputidnum + "Label";

            $('.panel').on('input propertychange', '.inputtitle', function () {
                $(this).parent().next('label').html('用户新增' + $(this).val());
            });
            $('.panel').on('click', '.ht_in_jian', function () {
                $(this).parents('.form-group').remove();
            });

            $('.panel').append('<div class="form-group">' +
            '<span class="formspan col-sm-6">标题：<input type="text" name="" class="inputtitle"/></span><label for="' + thisid + '" class="col-sm-6 control-label" style="display: none;" id="' + thisidLabel + '"></label>' +
            '<input id="' + thisid + '" name="' + thisid + '" type="file" data-show-caption="true" class="imagelimit">' +
            '<input type="button" value="-" class="ht_in_jian">' +
            '</div>');
        });
    })

    //图片信息保存
    $(".tubtn").click(function () {

        var flag = true;
        var sizeflag = true;
        var sizeTotal = 0;
        if (checkImageInput(this)) {
            $(".tubtn").attr("disabled", "disabled");
            var id = $("#id").val();
            var formData = new FormData();
            var strParms = "id=" + id;
            $(this).parent().prev().find("input").each(function () {

                var type = $(this).attr("type");
                if (type == "file" && $(this).attr("style") != "display:none") {
                    var name = $(this).attr("id");
                    var filename = $(this)[0].files[0];
                    var label_name = $('label[for="' + name + '"]').text();
                    if (label_name == null || label_name == "") {
                        flag = false;
                    }
                    if (filename == null) {
                        strParms = strParms + "&" + encodeURI(encodeURI(label_name)) + "=";
                    } else {
                        formData.append(label_name, filename);
                        sizeTotal = sizeTotal + filename.size;
                    }
                }
            });
            if (sizeTotal > 200 * 1024 * 1024) {
                sizeflag = false;
                /*alert("文件需小于200M");
                $(".tubtn").removeAttr("disabled");
                return;*/
            }
            if (flag && sizeflag) {
                $.ajax({
                    type: 'post',
                    url: '/company/saveCompanyUploadInfo?' + strParms,
                    cache: false,
                    data: formData,
                    contentType: false,
                    processData: false,
                    xhr: function () {
                        myXhr = $.ajaxSettings.xhr();
                        if (myXhr.upload) {
                            $('#J_progress_label').show();
                            myXhr.upload.addEventListener('progress', function (e) {
                                if (e.lengthComputable) {
                                    var percent = Math.floor(e.loaded / e.total * 100);
                                    if (percent <= 100) {
                                        $("#J_progress_label").html('已上传：' + percent + '%');
                                    }
                                    if (percent >= 100) {
                                        $("#J_progress_label").html('文件上传完毕，请等待处理...');
                                    }
                                }
                            }, false);
                        }
                        return myXhr;
                    },
                    success: function (data) {
                        $.myNotify.success(data.msg);
                        setTimeout(function () {
                            $("#J_progress_label").css('display', 'none');
                        }, 1000);
                    },
                    error: function (data) {
                        $(".tubtn").removeAttr("disabled");
                        $.myNotify.danger(data.msg);
                        setTimeout(function () {
                            $("#J_progress_label").css('display', 'none');
                        }, 1000);
                    }
                })
            } else if (!flag) {
                $(".tubtn").removeAttr("disabled");
                alert("标题不能为空");
            } else if (!sizeflag) {
                alert("文件需小于200M");
                $(".tubtn").removeAttr("disabled");
            }
        }
    })

    $('.form_datetime').datetimepicker({
        locale: 'zh-CN',
        language: 'zh-CN',
        format: "yyyy-mm-dd hh:ii:ss",
        sideBySide: true
    });

    $(".imagelimit").change(function () {
        var file = $(this)[0].files[0];
        if (file != null && file != undefined && file != "") {
            var name=file.name.toLowerCase();
            if (name.indexOf(".png") > 0 ||name.indexOf(".jpg") > 0 ||name.indexOf(".pdf") > 0 || name.indexOf(".rar") > 0 || name.indexOf(".zip") > 0 || name.indexOf(".jpeg") > 0 || name.indexOf(".gif") > 0 || name.indexOf(".bmp") > 0) {
            } else {
                alert("文件类型不支持");
                $(this).val("");
            }
        }
    })


</script>